<style>
p {
	margin:0
}
</style>
<div class="form-group" {guanlians}>
		<label class="col-xs-12 col-sm-3 col-md-2 right-label">{{check_show_lang('{title}')}}</label>
		<div class="col-xs-12 col-sm-8 col-lg-9">
				<div id="wangeditor-{name}"></div>
				<div class="help-block">{help}</div>
		</div>
</div>
<script type="text/javascript">
require(['wangeditor'], function(Editor){
	var editor = new Editor('#wangeditor-{name}')
	const $text1 = $('#wangeditor-{name}')
    editor.config.onchange = function (html) {
        scope.{tovalue}.{name} = html
    }
	editor.config.excludeMenus = [
        'emoticon'
    ];
	editor.config.colors = [
        '#000000',
        '#eeece0',
        '#1c487f',
        '#4d80bf',
        '#c24f4a',
        '#8baa4a',
        '#7b5ba1',
        '#46acc8',
        '#f9963b',
		'#ff0000',
		'#cc00ff',
		'#ff3366',
		'#660000',
		'#ff0099',
		'#ffcc00',
		'#ffff00',
		'#cc0000',
		'#cc6633',
		'#cc6699',
		'#ccff00',
		'#ccff99',
		'#990000',
		'#990066',
		'#9900cc',
		'#66ff00',
		'#66ffff',
		'#669900',
		'#333300',
		'#009900',
		'#00ff33',
        '#ffffff'
    ];
	editor.config.uploadImgMaxLength = 10;
	editor.config.height = 400;
	editor.config.zIndex = 10;
	editor.config.showLinkImg = false
	editor.config.uploadImgFromMedia = function () {
		  var res=function(result){
					if(result && result!=';'){
						//result=result.slice(1);
						if(scope.pagedata.wechat_image_url){
							var params={
								plugin:'core',
								action:'tools.choose_source',
								op:'wechat_image_url',
								query:'imagelist='+result,
								callback:function(list){
									var imglist = [];
									$.each(list,function(index,attachment){
										if(attachment){
											imglist.push({
												'src': attachment,
												'_src': attachment,
												//'width': '90%',
											  'alt': '图片'
											});
										}
									});
									//console.log(imglist);
									setTimeout(function(){
										var imghtml='';
										for(var i=0;i < imglist.length;i++){
											imghtml +='<img ng-click="previewImage(\''+imglist[i].src+'\')" src="'+imglist[i].src+'" style="max-width:100%;"/>';
										}
										editor.cmd.do(
											 'insertHTML',
											 `${imghtml}`
										)
									},1);
								}
							};
							scope.post_json(params);
						}else{
							result=result.split(';');
							var imglist = [];
							$.each(result,function(index,attachment){
								if(attachment){
									attachment=scope.tomedia(attachment);
									imglist.push({
										'src': attachment,
										'_src': attachment,
										//'width': '90%',
									  'alt': '图片'
									});
								}
							});
							//console.log(imglist);
							setTimeout(function(){
								var imghtml='';
								for(var i=0;i < imglist.length;i++){
									imghtml +='<img ng-click="previewImage(\''+imglist[i].src+'\')" src="'+imglist[i].src+'" style="max-width:100%;"/>';
								}
								editor.cmd.do(
									 'insertHTML',
									 `${imghtml}`
								)
							},1);
						}
					}
		  }
          scope.modal_func(res,'','tools.choose_source','','core','source_type=image&type=more');
    }
	editor.create()
	editor.txt.html(scope.{tovalue}.{name})
});
</script>
